package com.spsoft.dmzeinvoice.service.sandbox;

import com.spsoft.core.model.Result;
import com.spsoft.dmzeinvoice.common.enums.SandboxApiEnum;
import com.spsoft.dmzeinvoice.common.utils.SandboxRestTemplateUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


/**
 * 沙箱服务impl
 * 本服务不能提交到生产环境，仅供开发使用
 * @author cdl
 * @date 2024/04/19
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class SandboxServiceImpl implements SandboxService {


    final SandboxRestTemplateUtil sandboxRestTemplateUtil;
    @Override
    public Result<String> cxxnqyxx(String jrdwptbh, String sydwptbh, String access_signature, String nsrsbh, String ssjswjgDm) {
       StringBuffer sb = new StringBuffer();
       sb.append("{ ")
               .append("\"nsrsbh\":\"").append(nsrsbh).append("\",")
               .append("\"ssjswjgDm\":\"").append(ssjswjgDm).append("\"")
               .append("}");
        String re = sandboxRestTemplateUtil.postLeQi(jrdwptbh, sydwptbh, access_signature,
                SandboxApiEnum.LQSX_SWZJ_GT4_CXXNQYXX.getApiCode(), sb.toString());
        return Result.OK(re);
    }

    @Override
    public Result<String> gxqyxx(String jrdwptbh, String sydwptbh, String access_signature, String body) {

        String re = sandboxRestTemplateUtil.postLeQi(jrdwptbh, sydwptbh, access_signature,
                SandboxApiEnum.LQSX_SWZJ_GT4_GXQYXX.getApiCode(), body);
        return Result.OK(re);
    }

    @Override
    public Result<String> czqyxx(String jrdwptbh, String sydwptbh, String access_signature, String nsrsbh, String ssjswjgDm) {
        StringBuffer sb = new StringBuffer();
        sb.append("{ ")
                .append("\"nsrsbh\":\"").append(nsrsbh).append("\",")
                .append("\"ssjswjgDm\":\"").append(ssjswjgDm).append("\"")
                .append("}");
        String re = sandboxRestTemplateUtil.postLeQi(jrdwptbh, sydwptbh, access_signature,
                SandboxApiEnum.LQSX_SWZJ_GT4_CZQYXX.getApiCode(), sb.toString());
        return Result.OK(re);
    }

    @Override
    public Result<String> fprzdkztbg(String jrdwptbh, String sydwptbh, String access_signature, String xsfnsrsbh, String gmfnsrsbh, String fphm, String fprzztDm, String fpdkztDm) {
        StringBuffer sb = new StringBuffer();
        sb.append("{ ")
                .append("\"xsfnsrsbh\":\"").append(xsfnsrsbh).append("\",")
                .append("\"gmfnsrsbh\":\"").append(gmfnsrsbh).append("\",")
                .append("\"fphm\":\"").append(fphm).append("\",")
                .append("\"fprzztDm\":\"").append(fprzztDm).append("\",")
                .append("\"fpdkztDm\":\"").append(fpdkztDm).append("\"")
                .append("}");
        String re = sandboxRestTemplateUtil.postLeQi(jrdwptbh, sydwptbh, access_signature,
                SandboxApiEnum.LQSX_SWZJ_GT4_FPRZDKZTBG.getApiCode(), sb.toString());
        return Result.OK(re);
    }

    @Override
    public Result<String> zjnsrsxed(String jrdwptbh, String sydwptbh, String access_signature,
                                    String nsrsbh, String ssjswjgDm, String ssq, String ed) {
        StringBuffer sb = new StringBuffer();
        sb.append("{ ")
                .append("\"nsrsbh\":\"").append(nsrsbh).append("\",")
                .append("\"ssjswjgDm\":\"").append(ssjswjgDm).append("\",")
                .append("\"ssq\":\"").append(ssq).append("\",")
                .append("\"ed\":\"").append(ed).append("\"")
                .append("}");
        String re = sandboxRestTemplateUtil.postLeQi(jrdwptbh, sydwptbh, access_signature,
                SandboxApiEnum.LQSX_SWZJ_GT4_ZJNSRSXED.getApiCode(), sb.toString());
        return Result.OK(re);
    }

    @Override
    public Result<String> qyxxcsh(String jrdwptbh, String sydwptbh, String access_signature, String nsrsbh, String ssjswjgDm) {
        StringBuffer sb = new StringBuffer();
        sb.append("{ ")
                .append("\"nsrsbh\":\"").append(nsrsbh).append("\",")
                .append("\"ssjswjgDm\":\"").append(ssjswjgDm).append("\"")
                .append("}");
        String re = sandboxRestTemplateUtil.postLeQi(jrdwptbh, sydwptbh, access_signature,
                SandboxApiEnum.LQSX_SWZJ_GT4_QYXXCSH.getApiCode(), sb.toString());
        return Result.OK(re);
    }

    @Override
    public Result<String> sklpcsh(String jrdwptbh, String sydwptbh, String access_signature, String nsrsbh, String ssjswjgDm, String lzfppzDm, String sfzzfpbz) {
        StringBuffer sb = new StringBuffer();
        sb.append("{ ")
                .append("\"nsrsbh\":\"").append(nsrsbh).append("\",")
                .append("\"ssjswjgDm\":\"").append(ssjswjgDm).append("\",")
                .append("\"lzfppzDm\":\"").append(lzfppzDm).append("\",")
                .append("\"sfzzfpbz\":\"").append(sfzzfpbz).append("\"")
                .append("}");
        String re = sandboxRestTemplateUtil.postLeQi(jrdwptbh, sydwptbh, access_signature,
                SandboxApiEnum.LQSX_SWZJ_GT4_SKLPCSH.getApiCode(), sb.toString());
        return Result.OK(re);
    }
}
